/*
 * Copyright (c) 2005, 2014 vacoor
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 */
package org.vacoor.nothing.web.misc.cg.descriptor;

import java.util.ArrayList;
import java.util.List;

/**
 * @author vacoor
 */
public class MappedTable {
    private String code;
    private String table;
    private String typeName;
    private String fullTypeName;

    private List<MappedColumn> ids = new ArrayList<MappedColumn>();         // ID 列
    private List<MappedColumn> columns = new ArrayList<MappedColumn>();          // 属性列
    private List<OneToOne> oneToOne = new ArrayList<OneToOne>();      // One To One 关系
    private List<OneToMany> oneToMany = new ArrayList<OneToMany>();     // One To Many 关系
    private List<ManyToOne> manyToOne = new ArrayList<ManyToOne>();    // Many To One 关系
    private List<ManyToMany> manyToMany = new ArrayList<ManyToMany>();   // Many To Many 关系

    /**
     * 添加主键列
     */
    public MappedTable addId(MappedColumn column) {
        ids.add(column);
        return this;
    }

    /**
     * 添加属性列
     */
    public MappedTable addColumn(MappedColumn column) {
        columns.add(column);
        return this;
    }

    /**
     * 添加 One To One 关系
     */
    public MappedTable addOneToOne(OneToOne oneToOne) {
        this.oneToOne.add(oneToOne);
        return this;
    }

    /**
     * 添加 One To Many 关系
     */
    public MappedTable addOneToMany(OneToMany oneToMany) {
        this.oneToMany.add(oneToMany);
        return this;
    }

    /**
     * 添加 Many To One 关系
     */
    public MappedTable addManyToOne(ManyToOne manyToOne) {
        this.manyToOne.add(manyToOne);
        return this;
    }

    /**
     * 添加 Many To Many 关系
     */
    public MappedTable addManyToMany(ManyToMany manyToMany) {
        this.manyToMany.add(manyToMany);
        return this;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getTable() {
        return table;
    }

    public void setTable(String table) {
        this.table = table;
    }

    public String getTypeName() {
        return typeName;
    }

    public void setTypeName(String typeName) {
        this.typeName = typeName;
    }

    public String getFullTypeName() {
        return fullTypeName;
    }

    public void setFullTypeName(String fullTypeName) {
        this.fullTypeName = fullTypeName;
    }

    public List<MappedColumn> getIds() {
        return ids;
    }

    public List<MappedColumn> getColumns() {
        return columns;
    }

    public void setColumns(List<MappedColumn> columns) {
        this.columns = columns;
    }

    public List<OneToOne> getOneToOne() {
        return oneToOne;
    }

    public List<OneToMany> getOneToMany() {
        return oneToMany;
    }

    public List<ManyToOne> getManyToOne() {
        return manyToOne;
    }

    public List<ManyToMany> getManyToMany() {
        return manyToMany;
    }
}
